package com.cap.bts.crmdp.dealer.remind.dao.impl;

import java.util.List;

import javax.inject.Inject;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;

import com.cap.bts.crmdp.dealer.remind.dao.ICustomerGroupDao;
import com.cap.bts.crmdp.dealer.remind.domain.CustomerGroup;
import com.cap.bts.framework.common.dao.impl.BaseDaoImpl;
import com.cap.bts.framework.common.exception.AppException;

@Repository("customerGroupDao")
public class CustomerGroupDaoImpl extends BaseDaoImpl<CustomerGroup, Long> implements ICustomerGroupDao {
	
	@Inject
	public CustomerGroupDaoImpl(@Value("com.cap.bts.crmdp.dealer.remind.domain.CustomerGroup") Class<CustomerGroup> clazz) {
		super(clazz);
	}

	@Override
	public List<CustomerGroup> getCustomerGroupByDealerId(Long dealerId) throws AppException {
		String sql = "select * from tm_raw_group where dealer_id = '" + dealerId + "' GROUP BY group_name";
		return this.getListByNativeQuery(sql);
	}

	@Override
	public List<CustomerGroup> getCustomerGroupByDealerIdAndGroupName(Long dealerId,String groupName)
			throws AppException {
		String sql = "select * from tm_raw_group where dealer_id = '" + dealerId + "' and group_name = '" + groupName + "'";
		return this.getListByNativeQuery(sql);
	}

}
